package app.models;

import java.util.List;
import org.javalite.activejdbc.Model;
import static org.javalite.activejdbc.Model.findFirst;
import org.javalite.activejdbc.annotations.IdName;
import org.javalite.activejdbc.annotations.Table;

/**
 *
 * @author Kseniya Artsiukhova <kartsiukhova@productiveedge.com>
 */
@Table("publication_type")
@IdName("publication_type_id")
public class PublicationType extends Model {

    public void setPublicationTypeId(Long publicationTypeId) {
        setLong("publication_type_id", publicationTypeId);
    }

    public Long getPublicationTypeId() {
        return getLong("publication_type_id");
    }

    public void setPublicationType(String publicationType) {
        setString("type_name", publicationType);
    }

    public String getPublicationType() {
        return getString("type_name");
    }

    public static PublicationType getPublicationTypeByCode(String publicationTypeCode) {
        return findFirst("type_name = ?", publicationTypeCode);
    }

    public List<Genre> getGenres() {
        return getAll(Genre.class);
    }
}
